package com.OrderingSystem.service.impl;

import com.OrderingSystem.mapper.ProductCategoryMapper;
import com.OrderingSystem.pojo.ProductCategory;
import com.OrderingSystem.pojo.ProductInfo;
import com.OrderingSystem.service.ProductCategoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements ProductCategoryService {

    @Autowired
    ProductCategoryMapper productCategoryMapper;

    @Override
    public List<ProductCategory> selectAllProductCategory() {
        return productCategoryMapper.selectAllProductCategory();
    }

    //分页查询，带参数
    @Override
    public List<ProductCategory> selectAllProductCategory(Integer pageNum, Integer pageSize, ProductCategory productCategory) {
        // 使用MyBatis Plus的QueryWrapper构建查询条件
        QueryWrapper<ProductCategory> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(productCategory.getCategoryName() != null, "category_name", productCategory.getCategoryName());
        return productCategoryMapper.selectList(queryWrapper);
    }

}
